package com.xq.model;

import java.util.ArrayList;
import java.util.List;

import com.google.common.base.Joiner;

/*
 * CREATE TABLE `xqb_shop` (
 `id` int(11) NOT NULL AUTO_INCREMENT,
 `name` varchar(255) NOT NULL,
 `address` varchar(255) NOT NULL,
 `phones` varchar(255) DEFAULT NULL COMMENT '联系方式，电话之类的，逗号分隔',
 `xiaoQuId` int(11) DEFAULT NULL COMMENT '最靠近的小区，这个不是必须的',
 `detail` varchar(255) NOT NULL COMMENT '具体介绍',
 `images` varchar(255) DEFAULT NULL COMMENT '商店的相片，逗号分隔',
 `latitude` double NOT NULL COMMENT '精确的位置',
 `longtitude` double NOT NULL COMMENT '精确的位置',
 `createDate` timestamp NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建的时间',
 `tags` varchar(255) NOT NULL COMMENT '店面类型 如 饭店 超市 水粮油等',
 `lbsId` bigint(20) NOT NULL COMMENT '百度云上对应的记录的ID',
 PRIMARY KEY (`id`)
 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
 */

public class Shop extends BaseModel<Shop>
{

    public final static String TABLE_NAME = "xq_shop";
    public final static Shop dao = new Shop();
    
    public List<Shop> findByLBSIdList(List<Long> lbsIdList)
    {
    	if (lbsIdList == null || lbsIdList.isEmpty())
    	{
    		return new ArrayList<Shop>();
    	}
    	return find("select * from " + TABLE_NAME + " where lbsId in (" + Joiner.on(",").join(lbsIdList) + ")");
    }
    
    public void deleteByLBSId(long lbsId)
    {
    	List<Shop> shopList = find("select * from " + TABLE_NAME + " where lbsId = " + lbsId);
    	if (shopList != null)
    	{
    		for(Shop shop: shopList)
    		{
    			shop.delete();
    		}
    	}
    	
    }

}
